package com.zx._09_架构.扩展性.cpt2_pipeline;

import com.zx._09_架构.扩展性.cpt2_pipeline.context.PipelineContext;
import com.zx._09_架构.扩展性.cpt2_pipeline.context.StandardPipelineContext;
import com.zx._09_架构.扩展性.cpt2_pipeline.value.ForTestValue;
import com.zx._09_架构.扩展性.cpt2_pipeline.value.GraySwitchValue;
import com.zx._09_架构.扩展性.cpt2_pipeline.value.PipelineValue;

public class Main {

    /**
     * Pipeline----将多个PipelineValue串联起来的管道
     * PipelineValue----实际的任务节点
     * PipelineContext----用于管道上下文中数据的扭转
     * @param args
     */
    public static void main(String[] args) {
        // 管道初始化
        Pipeline pipeline = new StandardPipeline();

        // value扩展
        PipelineValue graySwitchValue = new GraySwitchValue();
        PipelineValue forTestValue = new ForTestValue();

        pipeline.addValue(graySwitchValue);
        pipeline.addValue(forTestValue);

        // 上下文
        PipelineContext pipelineContext = new StandardPipelineContext();
        pipelineContext.set("key1","value1");
        pipelineContext.set("key2","value2");

        // 调用管道
        pipeline.invoke(pipelineContext);

    }
}